package com.train.common.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * 学习项目类型：话术介绍，话术跟读，脱稿演练，模拟对话
 * 1-话术介绍，2-话术跟读，3-脱稿演练，4-模拟对话
 */

@Getter
@AllArgsConstructor
public enum StudyProjectTypeEnum implements ICommonEnum<Integer>  {

    INTRODUCE(1, "话术介绍"),
    READING(2, "话术跟读"),
    PRACTICE(3, "脱稿演练"),
    SIMULATED(4, "模拟对话")
    ;

    private Integer code;

    private String remark;

    public static StudyProjectTypeEnum getByCode(Integer code) {
        return Arrays.stream(StudyProjectTypeEnum.values())
                .filter(projectType -> projectType.getCode().equals(code))
                .findFirst()
                .orElse(null);
    }

    /* 可选：返回 Map<code, remark> */
    public static Map<Integer, String> toCodeRemarkMap() {
        return Arrays.stream(values())
                .collect(Collectors.toMap(StudyProjectTypeEnum::getCode, StudyProjectTypeEnum::getRemark));
    }
}
